<template>
  <section class="section section-container">
    <n-space :size="20">
      <div class="logo">当下景</div>
      <!-- 中台入口 -->
      <n-button
        target
        @click="handleSkip('/admin/#/login')"
        size="large"
        type="primary"
        icon="Pear"
      >
        <template #icon>
          <n-icon>
            <HappyOutline />
          </n-icon>
        </template>
        使用管理端
      </n-button>
      <!-- 小程序入口 -->
      <n-popover style="width: 300px" content-class="use-applet" width="trigger">
        <template #trigger>
          <n-button target size="large" type="info">
            <template #icon>
              <n-icon>
                <LaptopOutline />
              </n-icon>
            </template>
            使用小程序
          </n-button>
        </template>
        <div>微信搜索“当下景”小程序：</div>
        <img src="@/app/web/assets/search-applet.jpg" alt="" />
      </n-popover>
      <!-- 还未开放 -->
      <n-button
        target
        @click="handleSkip('/doc/index.html')"
        size="large"
        type="warning"
        disabled
      >
        <template #icon>
          <n-icon>
            <BookOutline />
          </n-icon>
        </template>
        查看文档
      </n-button>
      <n-button size="large" type="error" disabled>
        <template #icon>
          <n-icon>
            <CloudDownloadOutline />
          </n-icon>
        </template>
        下载程序
      </n-button>
    </n-space>
  </section>
</template>

<script lang="ts" setup>
import { useMessage, NPopover } from "naive-ui";

const handleSkip = (url) => {
  window.location.href = url;
};

const message = useMessage();
const channel = new BroadcastChannel("wicket");
channel.addEventListener("message", (event) => {
  message.success(event.data, {
    duration: 0,
  });
});

// const handleDownload = () => {
//   document.querySelector("#Download")?.scrollIntoView({
//     behavior: "smooth",
//   });
// };
</script>

<style lang="less" scoped>
.section {
  height: 80px;
  padding: 0 10%;
  background: transparent;
  color: #ffffff;
  text-align: center;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  width: 100%;
  z-index: 1;

  .logo {
    font-weight: bold;
    vertical-align: middle;
    font-size: 40px;
    letter-spacing: 3px;
    font-family: cursive;
  }
}
</style>
<style lang="less">
.use-applet {
  line-height: 40px;
  font-size: 16px;
  font-weight: bold;
  > img {
    width: 100%;
  }
}
</style>
